package cc.uncarbon.module.appapi.web.app;


import cc.uncarbon.framework.web.model.response.ApiResult;
import cc.uncarbon.module.appapi.constant.AppApiConstant;
import cc.uncarbon.module.appapi.model.request.BookOrderInsertOrUpdateDTO;
import cc.uncarbon.module.appapi.model.response.BookOrderBO;
import cc.uncarbon.module.appapi.model.vo.BookOrderByMonthVO;
import cc.uncarbon.module.appapi.model.vo.BookOrderVO;
import cc.uncarbon.module.appapi.service.BookOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "记账明细接口")
@RequestMapping(AppApiConstant.HTTP_API_URL_PREFIX + "/api/v1")
@RequiredArgsConstructor
@RestController
@Slf4j
public class HOSBookOrderController {

    private final BookOrderService bookOrderService;
    @Operation(summary = "记账新增")
    @PostMapping("/book/creade")
    public ApiResult BookOrderAdd(@RequestBody @Validated BookOrderInsertOrUpdateDTO dto){
        Long id = bookOrderService.appInsert(dto);
        return ApiResult.data( id);
    }


    @Operation(summary = "记账列表")
    @GetMapping("/book/list")
    public ApiResult<BookOrderVO> getList(@RequestParam(required = false) String date) {
        BookOrderVO data=bookOrderService.appList(date);
        return ApiResult.data(data);
    }
    @Operation(summary = "按月统计金额")
    @GetMapping("/book/listByMonth")
    public ApiResult getListByMonth(){
        return ApiResult.data(bookOrderService.getListByMonth());
    }
    @Operation(summary = "按类别统计金额")
    @GetMapping("/book/listByCategorty")
    public ApiResult listByCategorty(){
        return ApiResult.data(bookOrderService.getListByCategory());
    }


}
